package com.shuiyun.demo.job;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.shuiyun.demo.service.UserService;
import com.shuiyun.demo.utils.ScheduleUtils;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @program: qurtzDemo
 * @description:
 * @author: shuiyun
 * @create: 2020-09-24 10:39
 **/
public class JobDemo01  implements Job {

    @Autowired
    private UserService userService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap();
        String jsonParam = jobDataMap.getString(ScheduleUtils.JOB_PARAM_KEY);
        JSONObject jsonObject = JSON.parseObject(jsonParam);
        userService.getUser(jsonObject.getString("name"));
    }
}
